package com.gxsyh.nantie.user.management.provider.service.impl;

import com.gxsyh.nantie.user.management.provider.domain.TbDepartmentUser;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.gxsyh.nantie.user.management.provider.mapper.TbDepartmentUserMapper;
import com.gxsyh.nantie.user.management.provider.service.TbDepartmentUserService;
import tk.mybatis.mapper.entity.Example;

/**
 * @email yom535@outlook.com
 * @author: 刘锋嘉(Liu Fengjia)
 * @date: 2020/1/7
 * @time: 10:31
 * @Description: 
 */
@Service
public class TbDepartmentUserServiceImpl implements TbDepartmentUserService{

    @Resource
    private TbDepartmentUserMapper tbDepartmentUserMapper;

    @Override
    public int updateUserDepartment(Long userId, Long departmentId) {
        Example example=new Example(TbDepartmentUser.class);
        example.createCriteria().andEqualTo("userId",userId);
        TbDepartmentUser tbDepartmentUser=new TbDepartmentUser();
        tbDepartmentUser.setDepartmentId(departmentId);
        return tbDepartmentUserMapper.updateByExampleSelective(tbDepartmentUser,example);
    }

    @Override
    public int deleteUser(Long userId) {
        Example example=new Example(TbDepartmentUser.class);
        example.createCriteria().andEqualTo("userId",userId);
        return tbDepartmentUserMapper.deleteByExample(example);
    }
}
